<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="http://acegisecurity.org/authz" prefix="authz"%>
<%@ taglib uri="http://www.opensymphony.com/sitemesh/decorator" prefix="decorator"%>
<%@ taglib uri="http://www.opensymphony.com/sitemesh/page" prefix="page"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://www.springframework.org/security/tags" prefix="security"%>

<decorator:usePage id="thePage" />
<c:set var="pageProperties" value="${thePage.properties}" />
<c:choose>
	<c:when test="${pageProperties['meta.formName']!=null}">
		<c:set var="formName" value="${pageProperties['meta.formName']}" />
	</c:when>
	<c:otherwise>
		<c:set var="formName" value="mainForm" />
	</c:otherwise>
</c:choose>
<c:choose>
	<c:when test="${pageProperties['meta.formMethod']!=null}">
		<c:set var="formMethod" value="${pageProperties['meta.formMethod']}" />
	</c:when>
	<c:otherwise>
		<c:set var="formMethod" value="GET" />
	</c:otherwise>
</c:choose>
<c:set var="pageType" value="${pageProperties['meta.pageType']}" />
<c:choose>
	<c:when
		test="${pageType!='popup' and (empty param['decorate'] or param['decorate'] == 'yes')}">
		<html>
		<head>
		<title>管理平台</title>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<link href="${pageContext.request.contextPath}/stylesheets/stylesheet.css" rel="stylesheet" type="text/css">
		<link href="${pageContext.request.contextPath}/ext3.1/css/ext-all.css" rel="stylesheet" type="text/css" />
		<link href="${pageContext.request.contextPath}/ext3.1/css/ext-patch.css" rel="stylesheet" type="text/css" />
		<script type="text/javascript" src="${pageContext.request.contextPath}/ext3.1/js/ext-base.js"></script>
		<script type="text/javascript" src="${pageContext.request.contextPath}/ext3.1/js/ext-all.js"></script>
		<script type="text/javascript" src="${pageContext.request.contextPath}/ext3.1/js/debug.js"></script>
		<script type="text/javascript" src="${pageContext.request.contextPath}/ext3.1/js/ext-lang-zh_CN.js"></script>
		<script type="text/javascript" src="${pageContext.request.contextPath}/ext3.1/js/gridToExcel.js"></script>
		<script type="text/javascript" src="${pageContext.request.contextPath}/ext3.1/js/grid.js"></script>
		<script type="text/javascript" src="${pageContext.request.contextPath}/ext3.1/js/combobox.js"></script>
		<script type="text/javascript" src="${pageContext.request.contextPath}/ext3.1/js/window.js"></script>
		<script type="text/javascript" src="${pageContext.request.contextPath}/ext3.1/js/ajax.js"></script>
		<script type="text/javascript" src="${pageContext.request.contextPath}/ext3.1/js/error.js"></script>
		<script type="text/javascript" src="${pageContext.request.contextPath}/ext3.1/fileOperate/js/ThemePicker.js"></script>
		<script language=JavaScript src="${pageContext.request.contextPath}/scripts/common.js"></script>
		<script type="text/javascript" src="${pageContext.request.contextPath}/scripts/jquery-1.5.1.min.js"></script>
		<style type="text/css">
body {
	overflow: hidden;
}

#loading-mask {
	position: absolute;
	left: 0;
	top: 0;
	width: 100%;
	height: 100%;
	z-index: 20000;
	background-color: white;
}

#loading {
	position: absolute;
	left: 45%;
	top: 40%;
	padding: 2px;
	z-index: 20001;
	height: auto;
}

#loading img {
	margin-bottom: 5px;
}

#loading .loading-indicator {
	background: white;
	color: #555;
	font: bold 13px tahoma, arial, helvetica;
	padding: 10px;
	margin: 0;
	text-align: center;
	height: auto;
}

.goBack {
	background-image:
		url(${pageContext.request.contextPath}/images/menu_show_left.gif)
		!important;
}

.goForward {
	background-image:
		url(${pageContext.request.contextPath}/images/menu_show_right.gif)
		!important;
}

.goRefresh {
	background-image:
		url(${pageContext.request.contextPath}/images/menu_show_f5.gif)
		!important;
}

.toolBar_ {
	background: url(${pageContext.request.contextPath}/images/daohang.gif)
		repeat-x;
	height: 31px;
}

.x-toolbar-separator {
	background:
		url(${pageContext.request.contextPath}/images/new_grid-blue-split.gif)
		no-repeat !important;
}

.x-btn-text-mouseout {
	color: #FFFFFF !important;
}

.x-btn-text-mouseover {
	color: #000000 !important;
}

.x-export-excel {
	float: right;
	background-image:
		url(${pageContext.request.contextPath}/images/exportExcel.gif);
	width: 52px;
	height: 15px;
	cursor: pointer;
	margin: 0px 4px;
}

.x-export-dbf {
	float: right;
	background-image:
		url(${pageContext.request.contextPath}/images/report/icon_table.gif);
	width: 22px;
	height: 22px;
	cursor: pointer;
	margin: 0px 4px;
}

.x-tool-save-over {
	background-position: 0px -285px;
}
</style>
		<script type="text/javascript">
    		Ext.BLANK_IMAGE_URL = '${pageContext.request.contextPath}/ext3.1/images/default/s.gif';
    		var Constant_System_BasePath = '<%=(request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+request.getContextPath()+"/")%>';
    		var all_width  =  window.screen.width-7;
	 		var all_height;
	 		var colorWin;
	 		var themePicker;
    		Ext.onReady(function(){
    			if (Ext.isIE)
   	 			 all_height =  document.body.clientHeight - 130;
   	 			else
   	 			 all_height =  document.body.clientHeight - 130;
    		    Ext.QuickTips.init();
    		    Ext.form.Field.prototype.msgTarget = 'side';
    		    var tb = new Ext.Toolbar({
        		    height:'35px',
        		    style:'padding-left:40px;',
        		    cls:'toolBar_'
            		    });
    		    tb.render('toolbar');
    		    var backAction =new Ext.Action({text:'后退',iconCls: 'goBack',handler:goBack});
    		    var forwardAction =new Ext.Action({text:'前进',iconCls: 'goForward',handler:goForward});
    		    var refreshAction =new Ext.Action({text:'刷新',iconCls: 'goRefresh',handler:goRefresh});
    		    tb.add(backAction);
    		    tb.add({xtype: 'tbseparator'});
    		    tb.add(forwardAction);
    		    tb.add({xtype: 'tbseparator'});
    		    tb.add(refreshAction);
	        	tb.add('->');
	        	tb.add({xtype:'button',text:"换肤",handler:function(){
	            	if(colorWin == null)
	            	{
	            		colorWin = new Ext.Window({
	                		id : "colorWin",
		        			title : '选择颜色',
		        			width : 180,
		        			height : 100,
		        			resizable : false,
		        			frame:true,
		        			layout : 'fit',
		        			closeAction:"hide",
		        			items:[{contentEl:"color1"}]
		        		});
	            	}
	            	colorWin.show();
	            }});
	        	var colorValue = readCookie("style") || "BDD3EF";
	        	themePicker = new ThemePicker({renderTo:"color1"});
	        	if(colorValue != "BDD3EF")
	        	{
	        		themePicker.value = colorValue;
	        		themePicker.fireEvent("select",themePicker,colorValue);
	        	}
			 	tb.doLayout();
    		    new Ext.Viewport({
			        layout: 'border',
			        items: [{
			            region: 'north',
			            height: 94,
			            contentEl:'head',
				         border:false,
			            margins: '1 1 1 1'
			        }, {
			            region: 'center',
			            margins: '0 2 2 2',
			            bodyStyle:'overflow-y:auto;overflow-x:hidden;',
				         border:false,
				     		autoScroll:true,
			            contentEl:'content'
			        },{
			            region: 'south',
			            height:30,
			            id:'main_south_id',
			            margins: '0 2 2 2',
							html:'技术支持：' ,
							frame:true,
							bodyStyle:"text-align:center;"
			        }]
			    });
    		});
    		function goBack(btn)
		    {
    		    history.go(-1);
		    }
		    function goForward(btn)
		    {
		    	history.go(1);
		    }
		    function goRefresh(btn)
		    {
		    	history.go(0);
		    } 
    		function init()
    		{
    			sayHello();
    		}
    		function openHome()
    		{
        		//window.open("");
       		}
    	    		
    		function createCookie(name, value, days) {
    		    if (days) {
    		        var date = new Date();
    		        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
    		        var expires = "; expires=" + date.toGMTString();
    		    } else {
    		        expires = "";
    		    }
    		    document.cookie = name + "=" + value + expires + "; path=/";
    		}
    		function readCookie(name) {
    		    var nameEQ = name + "=",
    		        ca = document.cookie.split(';'),
    		        i,
    		        c,
    		        len = ca.length;
    		    for ( i = 0; i < len; i++) {
    		        c = ca[i];
    		        while (c.charAt(0) == ' ') {
    		            c = c.substring(1, c.length);
    		        }
    		        if (c.indexOf(nameEQ) == 0) {
    		            return c.substring(nameEQ.length, c.length);
    		        }
    		    }
    		    return null;
    		}
    		window.onunload = function (e) 
    		{
    		    var colorValue = themePicker.value || "BDD3EF";
    		    createCookie("style", colorValue, 365);
    		}
        </script>
		<decorator:head />
		</head>

		<body onload="<decorator:getProperty property="body.onload"/>;init();">
		<div id="color1"></div>
		<c:set var="username">
			<security:authentication property="principal.realName" />
		</c:set>
		<div id="head">
		<div id="main_bg">
			<div class="main_logo"></div>
			<div class="main_time">
				<span class="time_cjmg"> 
					<authz:authorize ifAnyGranted="ROLE_ADMINISTRATOR"></authz:authorize> 
				</span> <!--<a href="javascript:Ext.log('welcome');">bug</a>--> 
				<span id="dateZone" class="time_rq"></span>
				<span class="time_manager">
					<security:authentication property="principal.realName" />: 
					<a href='<%=request.getContextPath()%>/j_spring_security_logout'>注销</a>
				</span>
				<span class="time_helpF"><a href="#" onclick="openHelp()">帮助</a></span>
			</div>
		</div>
		<div id="toolbar"></div>
		</div>
		<!-- 正文 开始 -->
		<div id="content"><decorator:body /></div>
		<!-- 正文  结束 -->
		</body>
		<script type="text/javascript">
			/**********问候语、时间显示**********/
			function sayHello(){
				  var myDate=new   Date(<%=java.util.Calendar.getInstance().getTimeInMillis()%>);   
				  var myHour=myDate.getHours(); 
				  if(myHour<6)   
				  welcomeString="凌晨好";   
				  else   if(myHour<9)   
				  welcomeString="早上好";   
				  else   if(myHour<12)   
				  welcomeString="上午好";   
				  else   if(myHour<14)   
				  welcomeString="中午好";   
				  else   if(myHour<17)   
				  welcomeString="下午好";   
				  else   if(myHour<19)   
				  welcomeString="傍晚好";   
				  else     
				  welcomeString="夜里好";   

				  var arrayDay=["日","一","二","三","四","五","六"];   
				  
				 document.getElementById("dateZone").innerHTML = myDate.getFullYear()+"年"+(myDate.getMonth()+1)+"月"+myDate.getDate()+"日   "+"星期"+arrayDay[myDate.getDay()];
				  //window.setTimeout(sayHello,180000);
			}
		</script>
		</html>
	</c:when>

	<c:otherwise>
		<html>
		<head>
		<title><decorator:title default="管理平台" /></title>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<link href="${pageContext.request.contextPath}/stylesheets/stylesheet.css" rel="stylesheet" type="text/css">
		<decorator:head />
		</head>
		<body>
		<decorator:body />
		</body>
		</html>
	</c:otherwise>
</c:choose>

